<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script>
        //1.替换字符串 replace('被替换的字符串','替换的字符');
        //他只会替换第一个字符
        var str = 'andyandy';
        console.log(str.replace('a', 'b'));
        //有一个字符串 'oabcoefoxyozzopp' 要求吧里面所有的o替换为 *
        var str1 = 'oabcoefoxyozzopp';
        while (str1.indexOf('o') !== -1) {
            str1 = str1.replace('o', '*');
        }
        console.log(str1);

        //2.字符转换为数组 split('分隔符') 前面学过join 把数组转换为字符串
        var str2 = 'RED,pink,blue';
        console.log(str2.toLowerCase());
        console.log(str2.split(','));
        var str3 = 'red&pink&blue';
        console.log(str3.split('&'));

        // var str4 = ['red','blue','pink'];
        // console.log(str4.join('|'));


        var str4 = 'abaasdffggghhjjkkgfddsssss3444343';
        // while (str4.indexOf('g') !== -1) {
        //     str4 = str4.replace('g', '22');
        // }
        // console.log(str4);
        // console.log(str4.slice(1, 5));
        var o = {};
        for (var i = 0; i < str4.length; i++) {
            var chars = str4.charAt(i);
            if (o[chars]){
                o[chars]++;
            }else{
                o[chars] = 1;
            }
        }
        console.log(o);
        var max = 0;
        var ch = '';
        for (var k in o ){
            if (o[k] > max){
                max = o[k];
                ch = k;
            }
        }
        console.log(max);
        console.log(ch);
    </script>
</head>
<body>

</body>
</html>